package com.ruoyi.knowledge.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.knowledge.videocollect.domain.VideoCollect;
import com.ruoyi.knowledge.videocollect.service.IVideoCollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 视频收藏管理Controller
 * 
 * @author Jm
 * @date 2025-08-13
 */
@RestController
@RequestMapping("/videocollect/videocollect")
public class VideoCollectController extends BaseController
{
    @Autowired
    private IVideoCollectService videoCollectService;

    /**
     * 查询视频收藏管理列表
     */
    @PreAuthorize("@ss.hasPermi('videocollect:videocollect:list')")
    @GetMapping("/list")
    public TableDataInfo list(VideoCollect videoCollect)
    {
        startPage();
        List<VideoCollect> list = videoCollectService.selectVideoCollectList(videoCollect);
        return getDataTable(list);
    }

    /**
     * 导出视频收藏管理列表
     */
    @PreAuthorize("@ss.hasPermi('videocollect:videocollect:export')")
    @Log(title = "视频收藏管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VideoCollect videoCollect)
    {
        List<VideoCollect> list = videoCollectService.selectVideoCollectList(videoCollect);
        ExcelUtil<VideoCollect> util = new ExcelUtil<VideoCollect>(VideoCollect.class);
        util.exportExcel(response, list, "视频收藏管理数据");
    }

    /**
     * 获取视频收藏管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('videocollect:videocollect:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(videoCollectService.selectVideoCollectById(id));
    }

    /**
     * 新增视频收藏管理
     */
    @PreAuthorize("@ss.hasPermi('videocollect:videocollect:add')")
    @Log(title = "视频收藏管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VideoCollect videoCollect)
    {
        return toAjax(videoCollectService.insertVideoCollect(videoCollect));
    }

    /**
     * 修改视频收藏管理
     */
    @PreAuthorize("@ss.hasPermi('videocollect:videocollect:edit')")
    @Log(title = "视频收藏管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VideoCollect videoCollect)
    {
        return toAjax(videoCollectService.updateVideoCollect(videoCollect));
    }

    /**
     * 删除视频收藏管理
     */
    @PreAuthorize("@ss.hasPermi('videocollect:videocollect:remove')")
    @Log(title = "视频收藏管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(videoCollectService.deleteVideoCollectByIds(ids));
    }
}